﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kooboo.Commerce
{
    public static class ShippingCommand
    {
        public static decimal RateCost(this IShipping shipping, decimal weight)
        {
            if (shipping == null)
            {
                return 0m;
            }
            else
            {
                return shipping.ShippingCostRules.Where(i => i.From <= weight && weight <= i.To)
                    .Select(i => i.Cost)
                    .FirstOrDefault();
            }
        }
    }
}
